home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE10 / FILES / SETUPU.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-02-29  |  2.5 KB  |  119 lines

  1. unit Setupu;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, ExtCtrls, Buttons;
  8.  
  9. type
  10.   TPointList = class(TComponent)
  11.   protected
  12. {$ifdef Windows}
  13.     procedure WriteComponents(Writer: TWriter); override;
  14. {$else}
  15.     procedure GetChildren(Proc: TGetChildProc); override;
  16. {$endif}
  17.   end;
  18.  
  19.   TPointData = class(TComponent)
  20.   private
  21.     FX, FY: Word;
  22. {$ifdef Windows}
  23.   protected
  24.     function HasParent: Boolean; override;
  25. {$endif}
  26.   public
  27.     constructor CreateXY(AOwner: TComponent; AX, AY: Word);
  28.     procedure SwapXY;
  29.   published
  30.     property X: Word read FX write FX default 0;
  31.     property Y: Word read FY write FY default 0;
  32.   end;
  33.  
  34.   TForm1 = class(TForm)
  35.     procedure FormCreate(Sender: TObject);
  36.   private
  37.     PointList: TPointList;
  38.     procedure Loaded; override;
  39.   end;
  40.  
  41. var
  42.   Form1: TForm1;
  43.   Pt: TPointData;
  44.  
  45. const
  46. {$ifdef Windows}
  47.   ResFile = 'Points.R16';
  48. {$else}
  49.   ResFile = 'Points.R32';
  50. {$endif}
  51.  
  52. implementation
  53.  
  54. {$R *.DFM}
  55.  
  56. {$ifdef Windows}
  57. procedure TPointList.WriteComponents(Writer: TWriter);
  58. var
  59.   Loop: Integer;
  60. begin
  61.   { inherited version does nothing - no need to call it }
  62.   for Loop := 0 to ComponentCount - 1 do
  63.     Writer.WriteComponent(Components[Loop]);
  64. end;
  65. {$else}
  66. procedure TPointList.GetChildren(Proc: TGetChildProc);
  67. var
  68.   Loop: Integer;
  69. begin
  70.   { inherited version does nothing - no need to call it }
  71.   for Loop := 0 to ComponentCount - 1 do
  72.     Proc(Components[Loop]);
  73. end;
  74. {$endif}
  75.  
  76. constructor TPointData.CreateXY(AOwner: TComponent; AX, AY: Word);
  77. begin
  78.   inherited Create(AOwner);
  79.   FX := AX;
  80.   FY := AY;
  81. end;
  82.  
  83. {$ifdef Windows}
  84. function TPointData.HasParent: Boolean;
  85. begin
  86.   Result := True;
  87. end;
  88. {$endif}
  89.  
  90. procedure TPointData.SwapXY;
  91. begin
  92.   Tag := FX;
  93.   FX := FY;
  94.   FY := Tag;
  95. end;
  96.  
  97. procedure TForm1.Loaded;
  98. begin
  99.   inherited Loaded;
  100.   PointList := TPointList.Create(Self);
  101.   Pt := TPointData.CreateXY(PointList, 10, 10);
  102.   Pt := TPointData.CreateXY(PointList, 366, 10);
  103.   Pt := TPointData.CreateXY(PointList, 366, 191);
  104.   Pt := TPointData.CreateXY(PointList, 10, 191);
  105.   Pt := TPointData.CreateXY(PointList, 10, 10);
  106.   WriteComponentResFile(ResFile, PointList);
  107.   MessageDlg('Job done!', mtInformation, [mbOk], 0);
  108.   Application.Terminate;
  109. end;
  110.  
  111. procedure TForm1.FormCreate(Sender: TObject);
  112. begin
  113. {$ifdef Win32}
  114.   Application.ForceMainFormVisible := False;
  115. {$endif}
  116. end;
  117.  
  118. end.
  119.